/**
 * @author chenz
 */

const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;
const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;
var tabListener =
{
  QueryInterface: function(aIID)
  {
   if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
       aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
       aIID.equals(Components.interfaces.nsISupports))
     return this;
   throw Components.results.NS_NOINTERFACE;
  },

  onStateChange: function(aProgress, aRequest, aFlag, aStatus)
  {
   // If you use myListener for more than one tab/window, use
   // aProgress.DOMWindow to obtain the tab/window which triggers the state change
   if(aFlag & STATE_START)
   {
     websitenotes.tabwindows[aProgress.DOMWindow] = false;
   }
   if(aFlag & STATE_STOP)
   {
     websitenotes.tabwindows[aProgress.DOMWindow] = true;
		 websitenotes.onPageLoad();
   }
   return 0;
  },

  onLocationChange: function(aProgress, aRequest, aURI) {
		// This fires when the location bar changes; i.e load event is confirmed
    // or when the user switches tabs. If you use myListener for more than one tab/window,
    // use aProgress.DOMWindow to obtain the tab/window which triggered the change.
    if (websitenotes.tabwindows[aProgress.DOMWindow]) { websitenotes.onPageLoad(); }
    return 0;
  },

  // For definitions of the remaining functions see XULPlanet.com
  onProgressChange: function() {return 0;},
  onStatusChange: function() {return 0;},
  onSecurityChange: function() {return 0;},
  onLinkIconAvailable: function() {return 0;}
}